﻿using System.Collections.Generic;

namespace Basmus.Web.Topology
{
    internal class Topology : ITopology
    {
        private object _lock = new object();

        private readonly List<IDomain> _domainDeclarations = new List<IDomain>();

        public IEnumerable<IDomain> DomainDeclarations()
        {
            return _domainDeclarations;
        }


        public void Add(IDomain domain)
        {
            lock (_lock)
            {
                if (!_domainDeclarations.Contains(domain))
                {
                    _domainDeclarations.Add(domain);
                }
            }
        }

        public void Remove(IDomain domain)
        {
            lock (_lock)
            {
                if (_domainDeclarations.Contains(domain))
                {
                    _domainDeclarations.Remove(domain);
                }
            }
        }
    }
}
